﻿// Decompiled with JetBrains decompiler
// Type: MCM.Implementation.FluentBuilder.Models.DefaultSettingsPropertyFloatingIntegerBuilder
// Assembly: MCMv5, Version=5.10.2.0, Culture=neutral, PublicKeyToken=null
// MVID: 7AB326B9-B2B4-41C2-9177-68E944071101
// Assembly location: D:\steam\steamapps\workshop\content\261550\2859238197\bin\Win64_Shipping_Client\MCMv5.dll

using MCM.Abstractions;
using MCM.Abstractions.FluentBuilder;
using MCM.Abstractions.FluentBuilder.Models;
using MCM.Abstractions.Wrapper;
using MCM.Common;
using System;
using System.Collections.Generic;

#nullable enable
namespace MCM.Implementation.FluentBuilder.Models
{
  internal sealed class DefaultSettingsPropertyFloatingIntegerBuilder : 
    BaseDefaultSettingsPropertyBuilder<ISettingsPropertyFloatingIntegerBuilder>,
    ISettingsPropertyFloatingIntegerBuilder,
    ISettingsPropertyBuilder<ISettingsPropertyFloatingIntegerBuilder>,
    ISettingsPropertyBuilder,
    IPropertyDefinitionWithMinMax,
    IPropertyDefinitionWithFormat,
    IPropertyDefinitionWithActionFormat
  {
    public Decimal MinValue { get; }

    public Decimal MaxValue { get; }

    public string ValueFormat { get; private set; } = string.Empty;

    public Func<object, string>? ValueFormatFunc { get; private set; }

    internal DefaultSettingsPropertyFloatingIntegerBuilder(
      string id,
      string name,
      float minValue,
      float maxValue,
      IRef @ref)
      : base(id, name, @ref)
    {
      this.SettingsPropertyBuilder = (ISettingsPropertyFloatingIntegerBuilder) this;
      this.MinValue = (Decimal) minValue;
      this.MaxValue = (Decimal) maxValue;
    }

    public ISettingsPropertyBuilder AddValueFormat(string value)
    {
      if (this.ValueFormatFunc != null)
        throw new InvalidOperationException("AddActionValueFormat was already called!");
      this.ValueFormat = value;
      return (ISettingsPropertyBuilder) this.SettingsPropertyBuilder;
    }

    public override IEnumerable<IPropertyDefinitionBase> GetDefinitions()
    {
      return (IEnumerable<IPropertyDefinitionBase>) new IPropertyDefinitionBase[5]
      {
        (IPropertyDefinitionBase) new PropertyDefinitionWithMinMaxWrapper((object) this),
        (IPropertyDefinitionBase) new PropertyDefinitionWithFormatWrapper((object) this),
        (IPropertyDefinitionBase) new PropertyDefinitionWithActionFormatWrapper((object) this),
        (IPropertyDefinitionBase) new PropertyDefinitionWithCustomFormatterWrapper((object) this),
        (IPropertyDefinitionBase) new PropertyDefinitionWithIdWrapper((object) this)
      };
    }
  }
}
